package com.zpself.module.basic.枚举.解决开闭原则;

public enum ChannelRuleEnum {
    /**
     * 头条
     */
    TOUTIAO("toutiao",new TouTiaoChannelRule()),
    /**
     * 腾讯
     */
    TENCENT("tencent", new TouTiaoChannelRule());

    public String name;
    public GeneralChannelRule channel;
    ChannelRuleEnum(String name, TouTiaoChannelRule channel) {
        this.name =name;
        this.channel = channel;
    }

    //匹配
    public static ChannelRuleEnum match(String name){
        ChannelRuleEnum[] values = ChannelRuleEnum.values();
        for (ChannelRuleEnum value : values) {
            if(value.name.equals(name)){
                return value;
            }
        }
        return null;
    }
}